package com.wmm.fast.main.shop2Strategy;

import com.wmm.fast.main.shop2simplefactory.ShopCashiersInterface;
import com.wmm.fast.main.shop2simplefactory.ShopCashiersNormal;
import com.wmm.fast.main.shop2simplefactory.ShopCashiersRebate;
import com.wmm.fast.main.shop2simplefactory.ShopCashiersReturn;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 设计模式修炼
 * @Auther: Token360
 * @Date: 2018/9/5 14:41
 * @Description:
 */
public class ShopCashiersContext {

    private static final Logger log = LoggerFactory.getLogger(ShopCashiersContext.class);

    private ShopCashiersInterface shopCashiersInterface;

    /**
     * 单一的策略模式就直接传入Object ,
     * 策略+简单工厂就根据指定状态构造Object
     * */
    public ShopCashiersContext(int type){
        switch (type) {
            case 1:
                shopCashiersInterface = new ShopCashiersNormal();
                break;
            case 2:
                shopCashiersInterface = new ShopCashiersRebate(6);
                break;
            case 3:
                shopCashiersInterface = new ShopCashiersReturn(100,30);
                break;
        }
    }

    public void contextInterfaceStrategy(double payMoney) {
        shopCashiersInterface.acceptCash(payMoney);
    }

}
